package com.zis.auction.controller;

import com.alibaba.fastjson.JSONObject;
import com.zis.auction.model.AuctRegion;
import com.zis.auction.service.IAuctRegionInter;
import com.zis.core.SearchParams;
import org.beetl.sql.core.engine.PageQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

/**
 * Create by wangshen 2017/12/26
 */
@RestController
@RequestMapping("/api/auction/region")
public class AuctRegionController {

    @Autowired
    private IAuctRegionInter auctRegionInter;


    @RequestMapping(value = "/list", method = RequestMethod.POST)
    @ResponseBody
    public PageQuery<AuctRegion> findByPage(@RequestBody SearchParams params) throws Exception {
        return auctRegionInter.findByPage(params);
    }

    @RequestMapping(value = "/save", method = RequestMethod.POST)
    @ResponseBody
    public String insert(@RequestBody AuctRegion auctRegion) throws Exception {
        return auctRegionInter.insert(auctRegion);
    }

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    @ResponseBody
    public String update(@RequestBody AuctRegion auctRegion) throws Exception {
        return auctRegionInter.update(auctRegion);
    }

    @RequestMapping(value = "/delete/{id}", method = RequestMethod.GET)
    @ResponseBody
    public String delete(@PathVariable("id") String id) throws Exception{
        return auctRegionInter.delete(id);
    }

    @RequestMapping(value = "/list/json", method = RequestMethod.GET)
    @ResponseBody
    public List<JSONObject> findToList() throws Exception {
        return auctRegionInter.findToList();
    }
}
